// import path from 'path';
// import child_process from 'child_process';
// import { stat, mkdir, copyFile, readdir, constants, statSync, readdirSync, mkdirSync, copyFileSync, writeFileSync } from 'fs';

const child_process = require('child_process');

function doSCP(remotePath, localPath){
  // const remotePath = 'cnu228@202.204.209.228:/home/cnu228/Sparkers';
  // const localPath     = path.join(__dirname, "/www");
  console.log(`scp -r ${localPath} ${remotePath}`);

  const exec          = `scp -r ${localPath} ${remotePath}`;

  // 必须设置shell为true才可以执行
  // 设置detached为false，不弹出cmd界面，也就无法显示上传进度
  // const nscp = child_process.spawnSync(exec, [], {shell: true, detached: true});
  child_process.execSync(exec, {stdio:[0,1,2]});
}

module.exports = {
  doSCP,
}
